def dfs(s,ans,path,i,n):
    if i==n:
        ans.append(path[:])
        return 
    for j in range(i,n):
        if huiwen(s[i:j+1]):
            path.append(s[i:j+1])
            dfs(s,ans,path,j+1,n)
            path.pop()

def huiwen(s):
    n=len(s)
    for i in range(n//2):
        if s[i]!=s[n-1-i]: return False 
    return True

def solve(s):
    ans=[]
    n=len(s)
    dfs(s,ans,[],0,n)
    return ans 

print(solve('aab'))
print(solve('a'))